﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Add_User_Ramdomly_lib;
using System.IO;
using System.Xml.Linq;
using System.Xml;

namespace ConsoleApplication2
{
   
    class Program 
    {
        static IEnumerable<XElement> GetNextNode(TextReader stringReader)
        {
            using (System.Xml.XmlReader reader = XmlReader.Create(stringReader))
            {
                reader.MoveToContent();
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:
                            if (reader.Name == "node")
                            {
                                XElement el = XElement.ReadFrom(reader) as XElement;
                                if (el != null)
                                    if (el.Element("tag") != null)
                                        yield return el;
                            }
                            break;
                    }
                }
            }
        }

        
        static void Main(string[] args)
        {

            using (var reader = new StreamReader(@"C:\ws\My Project\germany\germany.osm", Encoding.UTF8))
            {
                foreach (var el in GetNextNode(reader))
                {


                    var attrs = new Dictionary<string, string>();

                    foreach (var tag in el.Elements("tag"))
                    {
                        var k = tag.Attribute("k");
                        var v = tag.Attribute("v");
                        if (k != null && v != null)
                            attrs.Add(k.Value, v.Value);
                    }
                }
            }


            /*string con = @"Data Source=CLAUDE-PC;Initial Catalog=DocsRoomManagement;Integrated Security=True";

            string cmd = "SELECT * FROM Users";

            SqlConnection connection = new SqlConnection(con);
            SqlCommand command = new SqlCommand(cmd, connection);

            connection.Open();
            SqlDataReader reader = command.ExecuteReader();

            Users user = new Users();


            if (reader.Read())
            {
                string name = (string)reader["First_Name"];

                Console.WriteLine(name);            
            }

            connection.Close();  
            */
            
        }
    }
}
